use std::{collections::HashSet, fs::read_to_string};


pub fn min_edge_prime_num(number: u32) -> String {
    let mut n = 5;
    let mut prime_number = 3; // 初始化质数数量
    let mut total_number = 5; // 初始化总数
    let mut percent: u32;
    let sourc  = read_to_string("table").unwrap();
    let source: HashSet<u128> = sourc
    .split_whitespace()
    .map(|s| s.parse::<u128>().unwrap_or_else(|e| {
        eprintln!("failed '{}'  {}", s, e);
        panic!("gfniag");
    }))
    .collect();
    loop {
        
        let tmp_c = n * n - (n - 1);      // n^2 - (n-1)
        let tmp_b = n * n - 2 * (n - 1);  // n^2 - 2*(n-1)
        let tmp_a = n * n - 3 * (n - 1);  // n^2 - 3*(n-1)
        
        if source.contains(&tmp_a) {

            prime_number += 1;
            // ve.push(tmp_a);
        }
        if source.contains(&tmp_b) {
            prime_number += 1;
            // ve.push(tmp_b);
        }
        if source.contains(&tmp_c) {
            prime_number += 1;
            // ve.push(tmp_c);
        }
        
        total_number += 4; 
        
        percent = ((prime_number as f64 / total_number as f64) * 100f64) as u32;
        if percent < number {
            // for i in ve {
            //     print!("{} ",i);
            // }
            // println!("");
            break;
        }

        n += 2; 
    }

    format!("{},{}", n, prime_number)
}
